package com.ytktt.study.week12.task7;

import com.ytktt.study.week12.task7.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.Random;

/**
 * TODO
 *
 * @author ytk
 */
@SpringBootApplication
public class ProviderApplication implements ApplicationRunner {

    @Autowired
    private OrderService orderService;
    private final Random random = new Random();

    public static void main(String[] args) {
        SpringApplication.run(ProviderApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        while (true) {
            this.orderService.providerOrder();
            Thread.sleep(this.random.nextInt(1600) + 1000);
        }
    }
}
